<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./iconfont/iconfont.css">
    <link rel="stylesheet" href="./css/01.css">
</head>

<body>
    <header>
        <i class="iconfont icon-zuojiantou"></i>
        <span>注册账号</span>
    </header>

    <main>
        <nav>
            <div class="store">
                <img src="./imgs/store.png" alt="">
                <!-- <i class="iconfont icon-shangdian"></i> -->
            </div>
        </nav>
        <div class="inp"><input type="text" placeholder="请输入账号" id="username"></div>
        <div class="inp"><input type="text" placeholder="请输入密码" id="password"></div>
        <div class="inp"><input type="text" placeholder="请再次输入密码" id="confirm"></div>
        <button>立即注册</button>
        <span>已有账号，立即登录</span>
    </main>

    <script src="./http.js"></script>
    <script>
        let regiDom = document.querySelector('button')

        regiDom.addEventListener('click', function () {
            let nameDom = document.querySelector('#username');
            let passDom = document.querySelector('#password');
            let confirmDom = document.querySelector('#confirm');
            const data = {
                account: nameDom.value,
                password: passDom.value
            }
            if (!nameDom.value || !passDom.value || !confirmDom.value) {
                return alert('用户名、密码和确认密码不能为空');
            }
            if (passDom.value !== confirmDom.value) {
                return alert('密码和确认密码不匹配');
            }
            http.post('http://8.137.157.16:9000/user/register', data, function (res) {
                console.log(res);
            });

        });
    </script>
</body>

</html>